package com.banshuibao.bsb_android.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.banshuibao.bsb_android.R;
import com.banshuibao.bsb_android.model.TobeModel;
import com.banshuibao.bsb_android.util.PriceUtil;
import com.banshuibao.bsb_android.util.TimeUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/12/20.
 */

public class TobeAdapter extends MineBaseAdapter<TobeModel.DataBean>{
    private Context context;
    public TobeAdapter(Context context, List<TobeModel.DataBean> data, int layoutResId) {
        super(context, data, layoutResId);
        this.context = context;
    }

    @Override
    protected void bindData(ViewHolder holder, TobeModel.DataBean item) {
        TextView content = (TextView) holder.getView(R.id.respond_content);
        ImageView imageView = (ImageView) holder.getView(R.id.respond_qiang);
        TextView date = (TextView) holder.getView(R.id.respond_date);
        TextView price_tv = (TextView) holder.getView(R.id.qPrice);
        String price = PriceUtil.FormatDecimal(item.getPrice());
        price_tv.setText(price+"元");
        content.setText(item.getContent());
        String time = null;
        if (item.getCreateDate() != 0) {
            time = TimeUtil.format(item.getCreateDate());
        } else {
            time = "";
        }
        date.setText(time);
        //可否抢答
        String status = item.getStatus();
        if (status.equals("0")) {
            price_tv.setTextColor(context.getResources().getColor(R.color.price));
            imageView.setImageResource(R.drawable.qiang);
        } else if (status.equals("1")) {
            price_tv.setTextColor(context.getResources().getColor(R.color.text_default));
            imageView.setImageResource(R.drawable.qiang_no);
        }
    }
}
